<?php

namespace robot;

class Robot 
{
	
	public static function send($content)
	{
		// todo::调机器人接口
		
		$url = "http://openapi.tuling123.com/openapi/api/v2";

		$methon = "post";

		$data = [
			'reqType'=>0,
			'perception'=>[
				'inputText'=>[
					'text'=>$content
				]
			],
			'userInfo'=>[
				'apiKey'=>'facc47b9f3afc7a493121bf6aacab53f',
				'userId'=>1
			]
		];

		$ch = curl_init();

		curl_setopt($ch, CURLOPT_POST, 1);

		curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

		curl_setopt($ch, CURLOPT_URL, $url);

        curl_setopt($ch, CURLOPT_TIMEOUT, 5);

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        //头部要不要
		curl_setopt($ch, CURLOPT_HEADER, 0);

		$res = curl_exec($ch);

		curl_close($ch);
		return $res;

	}
}